package io.renren.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import cn.hutool.core.util.StrUtil;
import com.github.xiaoymin.knife4j.core.util.CommonUtils;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.common.utils.ConvertUtils;
import io.renren.core.dao.LearnQuestionInfoDao;
import io.renren.core.dto.LearnQuestionInfoDTO;
import io.renren.core.entity.LearnQuestionInfoEntity;
import io.renren.core.service.LearnQuestionInfoService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 测试题
 *
 * @author Ark 6980gong@gmail.com
 * @since 1.0.0 2024-05-09
 */
@Service
public class LearnQuestionInfoServiceImpl extends CrudServiceImpl<LearnQuestionInfoDao, LearnQuestionInfoEntity, LearnQuestionInfoDTO> implements LearnQuestionInfoService {

    @Override
    public QueryWrapper<LearnQuestionInfoEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<LearnQuestionInfoEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public List<LearnQuestionInfoDTO> listByTypeId(Long typeId) {
        List<LearnQuestionInfoEntity> entityList = baseDao.selectList(new QueryWrapper<LearnQuestionInfoEntity>().eq("question_type_id", typeId));
        return ConvertUtils.sourceToTarget(entityList, currentDtoClass());
    }
}